-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Implement snapshot saving #57
Conversation
5a55536
to
8d3edd4
Compare
011e2d9
to
b72b4f0
Compare
e5e7fd3
to
4ff42b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more thoughts. I think we need to think about how we handle meta_pvs
, because at the very least, they are never initialized / configured in our current framework.
""" | ||
logger.debug("Gathering PVs to read") | ||
pvs = self._gather_pvs(entry) | ||
pvs.extend(Collection.meta_pvs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm realizing now that we're defining meta PVs as a class variable, which prevents us from properly representing capturing changes to the meta_pv list. More concretely, if we:
- define one collection expecting a set of meta_pvs
- change the (global) list of meta_pvs
- take a snapshot with that same old collection
The new snapshot will pull the new meta_pvs, and might inadvertently be missing / duplicate PVs. This could be the behavior we want, but I think we need to find a way to make it more obvious if we do. Alternately we record meta_pvs as an instance variable (not class variable), and fill it with the global configuration on creation.
We also need to determine how we capture this in the Filestore backend, as currently this won't be recorded properly. This probably needs to be a separate dictionary / store external to the Root
tree that gets stored
4ff42b6
to
44a04ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Let's get this in 👍
The test didn't consider Readback handling because sample_database doesn't include any Readbacks. Rather than modify sample_database and possibly affect other tests, I've added a minimal fixture for considering a single Setpoint-Readback pair.
44a04ba
to
0fcf43b
Compare
Description
Snapshot
saving (closes Implement saving a Snapshot #32 )Client._build_snapshot
andClient._gather_pvs
Client._gather_data
to accept any type ofEntry
, and make iterative rather than recursiveMotivation and Context
Client.snap
itself is simple: it gathers all of the PVs in an entry, adds in the meta PVs, asynchronously fetches data for each PV, and then builds the snapshot. This method is namedsnap
becausesave
is currently used for the method that writes entries to the backend.Since we want a function to gather all of the PVs from an entry, I decided to avoid code duplication by adding that functionality to
Client._gather_data
. This extension needed some messy code to handle all of the parameter permutations, which I was able to simplify by changing the method to be iterative. I also usehasattr
rather than type checks to avoid length conditionals. I includedClient._gather_pvs
as a convenience method.Fetching the data is straightforward due to
ControlLayer._get_list
.Building the snapshot uses a simple depth-first process.
Alternative Designs
One major alternative was to have each
Entry
subclass implement method to gather its PVs. This conflicts with the current system because the entry classes don't have access to the backend to process UUIDs.How Has This Been Tested?
New and updated tests in
test_client.py
Where Has This Been Documented?
This PR, docstrings
Pre-merge checklist
docs/pre-release-notes.sh
and created a pre-release documentation page